<template>
	<view class="main1">
		<view class="table" v-if="level == 3">
			<view class="table_top">
				<view class="th">团队ID</view>
				<view class="th">团队人数</view>
				<view class="th">收入详情</view>
			</view>
			<scroll-view :scroll-top="scrollTop" scroll-y="false" class="scroll-Y" @scrolltoupper="upper"
				@scrolltolower="lower" @scroll="scroll">
				<view class="scroll-view-item" v-for="(v,k) in Teamearningslist" :key="k">
					<view class="tdd">
						<view class="td">
							{{v.user_id}}
						</view>
						<view class="td">
							{{v.count}}
						</view>
						<view class="td">
							<view class="td3_left">{{v.money}}元</view>
							<view class="td3_right" @click="dian(k)">
								<u-icon name="arrow-right" color="#FF8484" size="30" v-if="v.check == false"></u-icon>
								<u-icon name="arrow-down" color="#FF8484" size="30" v-if="v.check == true"></u-icon>
							</view>
						</view>
					</view>
					<view class="tcc" v-if="v.check == true">
						<view class="tcc_top">
							<view class="thh thhh">博主</view>
							<view class="thh thhh">收益</view>
						</view>
						<view class="tcc_top" v-for="(item,index) in v.data" :key="index">
							<view class="thh">{{item.user_id}}</view>
							<view class="thh">{{item.money}}元</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="table" v-if="level == 2">
			<view class="table_top">
				<view class="th2">用户ID</view>
				<view class="th2">收入详情</view>
			</view>
			<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
				@scrolltolower="lower" @scroll="scroll">
				<view class="scroll-view-item" v-for="(v,k) in Teamearningslist" :key="k">
					<view class="tdd">
						<view class="td2">
							{{v.user_id}}
						</view>
						<view class="td2">
							{{v.money}}元
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "Teamearnings",
		props: {
			Teamearningslist: {
				type: Array,
				default: () => []
			},
			level: {
				type: Number,
				default: () => ''
			}
		},
		data() {
			return {
				scrollTop: 0,
				oldscrollTop: '',
				height: '',
			};
		},
		created() {
			this.oldscrollTop = uni.getStorageSync('oldscrollTop') || ''
			this.goTop(this.oldscrollTop)
		},
		beforeDestroy() {
			uni.setStorageSync('oldscrollTop', this.oldscrollTop)
		},
		watch: {
			'Teamearningslist': {
				handler: function(newValue, oldValue) {
					if (newValue.length != oldValue.length) {
						this.goTop(0)
					}
				},
				// deep: true
			}
		},
		methods: {
			upper(e) {},
			lower(e) {
				this.$emit('aaa', 4)
			},
			scroll(e) {
				this.oldscrollTop = e.detail.scrollTop
			},
			goTop(e) {
				this.scrollTop = this.oldscrollTop
				this.$nextTick(function() {
					this.scrollTop = e
				});
			},
			dian(k) {
				this.$emit('bbb', k)
				let height = k * 34
				this.goTop(height)
			},
		},
	}
</script>

<style lang="less" scoped>
	@import url("Teamearnings.less");
</style>